/*
 * Copyright (c) 2015-2018 Sfkj Science And Technology Co.,Ltd.
 * All Rights Reserved.
 * This software is the confidential and proprietary information of
 * Sfkj Science And Technology Co.,Ltd.
 * ("Confidential Information").You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Sfkj.
 */
package com.sfkj.walk.query.user;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate;
import com.sfkj.walk.mongo.AbstractDocument;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.axonframework.domain.ImageUrl;

@Data
@EqualsAndHashCode(callSuper = true)
public class User extends AbstractDocument {

    private static final long serialVersionUID = 223516524838419577L;

    @JsonIgnore
    private String password;
    private String name;
    private ImageUrl avatar;
    private String introduction;

    @JsonIgnore
    private String phone;

    public String getTextPhone() {
        return phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
    }

    public static Predicate buildBy(String id) {
        BooleanBuilder conditions = new BooleanBuilder();
        conditions.and(QUser.user.id.eq(id));
        return conditions;
    }
}